/**
 * 物品出库js
 */
var j=0;
var editRow1=undefined;
var editRow =undefined;
var mainrow=undefined;
var currows=null;
var filename="出库信息";
var grid='';
var exportString='';
var arrname=['客户姓名','物品名称','物品数量','SN','物品去向'];
$(function(){

	grid=$("#goods").datagrid({
	    url:path+'billmaster/outboundorder.html',  
	    //queryParams:{},  
	    loadMsg:'数据加载中请稍后……',  
	    pagination: true, 
	    height:480,
	    remoteSort:false,
	    fit:true,
	    pageList: [15,20,30,40,1000000],
	    pageSize: 15,
	    rownumbers: true,  
	    fitColumns:true,
	    columns:[[ 
	        {field:'id',checkbox:true,title:''},
	        {field:'billno',title: '出库编号',align: 'center',width:65,sortable:true},
	      
	        {field:'createname',title: '操作人',align: 'center',width:65,sortable:true}, 	        
			{field:'bilddate',title: '完成时间',align: 'center',width:65,sortable:true},
			{field:'states',title: '出库状态',align: 'center',width:65,sortable:true 	
			},
			  {field:'remark',title: '备注',align: 'center',width:65,sortable:true},
			//{field:'billtype',title: '单据类型',align: 'center',width:65,sortable:true },
			{field:'ss',title: '查看记录',align: 'center',formatter:function(value,rowData,rowIndex){
			    	return "<button href='#' onclick=viewdate('"+rowData.id+"','"+rowData.billno+"','"+rowData.remark+"')>查看</button>";     		        
		   },width:65,sortablebill:true  
		}
	    ]],	    
	    singleSelect : false,
	    selectOnCheck: true,
	    checkOnSelect: true,
	    rowStyler: function(index,row){
			if (row.states=='已完成'){
				return 'background-color:#F0F0F0;color:gray;';
			}
		},
	    onClickRow:function(rowIndex, rowData){
	    	if(rowData.states=='已完成'){
	    		$("#goods").datagrid("unselectRow",rowIndex);
	    	}               
	    	mainrow=rowData;
	    },
	    onRowContextMenu:function(e, rowIndex, rowData){
	    	e.preventDefault();
	    	
	    },
	    onCheck:function(rowIndex, rowData){
	    	if(rowData.states=='已完成'){
	    		$("#goods").datagrid("unselectRow",rowIndex);
	    	}
    	},   
	    onBeforeLoad:function(){

        },
	    onLoadSuccess:function(date){
	    	//$('#mainadd').linkbutton('disable');	
	    	if(role==1){ //如果角色是guest 不能编辑数据
	    		$(" .datagrid-toolbar").hide();
	    		//$('#ok').linkbutton('disable');
	    	}
	    	$(".datagrid-header-check input[type='checkbox']").attr("disabled","disabled");
	    	
	    },
		toolbar: [{
			iconCls: 'icon-add',
			text:'新增',
			id:'mainadd',
			handler: function(){
				j++;
			  //var billon= "HK"+formatDateTime(new Date())+preZeroFill(j, 2);
				var billon='';
			   addGoods(billon);
			}
		},'-',{
			iconCls: 'icon-edit',
			text:'编辑',
			id:'mainedit',
			handler: function(){ 
				editdate();
			}
		},'-',{
			iconCls: 'icon-remove',
			text:'删除',
			id:'maindel',
			handler: function(){ 
				delmaindate();
			}
		},'-',{
			iconCls: 'icon-ok',
			text:'提交',
			id:'mainsubmit',
			handler: function(){ 
				mainsubmit();
			}
		},'-',{
			iconCls: 'icon-redo',
			text:'导出草稿',
			id:'mainexp',
			handler: function(){ 
				mainexp();
			}
		},'-',{
			iconCls: 'icon-redo',
			text:'导出全部',
			id:'mainthispagexp',
			handler: function(){ 
				mainthispagexp();
			}
		}]

	}); 
	
	  var p = $('#goods').datagrid('getPager'); 
	    $(p).pagination({ 
	        pageSize: 15,//每页显示的记录条数，默认为10 
	        pageList: [15,20,30,40,1000000],//可以设置每页记录条数的列表 
	        beforePageText: '第',//页数文本框前显示的汉字 
	        afterPageText: '页    共 {pages} 页', 
	        displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'
	    });     
		
});
/**
 * 新增物品
 */
function addGoods(billno){	
	$('#goodsadd').window('open');
	$('#addgoodsform')[0].reset();
	$('#goodsadd').panel('setTitle','新增物品出库');
	$("#tag").attr("value","0");
	$("#billno").attr("value",billno);
	showdtl(0,0);
}

/***
 * 选择字段查询数据
 * @param value
 * @param name
 */
function searcherGoods(value,name){
	var url=path+'billmaster/outboundorder.html?field='+name+"&searchertext="+value;
	url=encodeURI(url);
	url=encodeURI(url);
	$("#goods").datagrid("load",url);
}
/**
 * tag=0 新增页面
 * tag=1 编辑页面
 * tag=10 查看页面
 * ***/
function showdtl(tag,parentid){
  var uri="";
  uri=path+'billdetail/querybilldatebyparentid.html?billtype=出库单&parentid='+parentid;
  var datagrid1; //定义全局变量datagrid            
  var onl=null;
  uri=encodeURI(uri);
  uri=encodeURI(uri);

  datagrid1 =$("#outoderdtl").datagrid({
	    url:uri,
	    loadMsg:'数据加载中请稍后……',  
	    //pagination: true, 
	    height:540,
	    remoteSort:false,
	    rownumbers: true, 
	    singleSelect:true,
	    fitColumns:true,
	    onAfterEdit: function (rowIndex, rowData, changes) {  
	    	},
	    onLoadSuccess:function (rowIndex, rowData) { 
	    			 if(tag==10){  //禁用按钮
	    				// $(" .datagrid-toolbar").hide();
	    				 $('#dtladd').linkbutton('disable');
	    				 $('#dtlsave').linkbutton('disable');
	    			 }   
		},
		onDblClickCell: function (rowIndex, rowData) {
			if(tag==10){
				
			}else{
				editRow1 = undefined;    
				datagrid1.datagrid("acceptChanges"); 
		    	datagrid1.datagrid("beginEdit", rowIndex);    
	    		editRow1 = rowIndex;    
			}
	    	  
	    },
	    onClickRow:function(rowIndex, rowData){
	    	currows=rowData;
	    },
	    columns:[[ 
			{field:'clientname',title: '客户姓名',align: 'center',width:65,sortablebill:true,
				editor: { type: 'combogrid', options: { 
					url:path+'clientinfo/getallClientinfo.html?a=1',  
					panelWidth:300,
					panelHeight:320,
					//fit:false,
					mode:'remote',
					idField:'clientname',    //主键是ID
				    textField:'clientname',    //文本显示是姓名
				    pagination:true,
				    fitColumns:true,
				    pageSize:10,
				    pageList:[10,15,20],
					columns:[[    
				                {field:'id',title:'ID',width:60,hidden:true},    
				                {field:'clientname',title:'姓名',width:100},    
				                {field:'tel',title:'电话',width:160,hidden:true}   
				            ]],
				            onShowPanel:function(){  //当下拉面板显示的时候触发
				            	var drow = $('#outoderdtl').datagrid('getSelected');
				            },
				            onSelect: function(rowIndex,rowData){  //赋值客户id
				               	setTimeout(function () {
						    	     var drow = $('#outoderdtl').datagrid('getSelected');
					                 var index = $('#outoderdtl').datagrid('getRowIndex', drow);
					                 editRow1 = undefined;    
					 				 datagrid1.datagrid("acceptChanges");   
					 				 datagrid1.datagrid("unselectAll"); 
					                 datagrid1.datagrid('updateRow', { index: index, row: {clientid:rowData.id} });
					                 datagrid1.datagrid("acceptChanges"); 
					                 $('#outoderdtl').datagrid('endEdit', index).datagrid('refreshRow', index).datagrid('selectRow', index).datagrid('beginEdit', index);
						    	},10);
				            }
				}
			}
			},
			{field:'clientid',title: '客户ID',align: 'center',width:85,sortablebill:true,hidden:true},
			//{field:'assetdescription',title: '资产描述',align: 'center',width:85,sortablebill:true,	editor: { type: 'validatebox', options: { required: true} }},
			{field:'goodname',title: '物品名称',align: 'center',width:80,sortablebill:true,
				editor: { type: 'combogrid', options: { 
					url:path+'billdetail/getgoodsexistout.html',   
					panelWidth:900,
					panelHeight:290,
					mode:'remote',
					idField:'goodsname',    //主键是ID
				    textField:'goodsname',    //文本显示是姓名
				    pagination:true,
				    fitColumns:true,
				    pageSize:10,
				    pageList:[10,15,20],
					required: true,
				    columns:[[    
				                {field:'id',title:'ID',width:10,hidden:true},    
				                {field:'goodname',title:'物品名称',width:120},   
				                {field:'specifications',title:'规格型号',width:200},  
				                {field:'beiyon',title:'库存编号',width:100},
				                {field:'stockrate',title:'库存量',width:60},
				                {field:'unit',title:'单位',width:50} , 
				                {field:'snno',title:'SN',width:80,hidden:true} , 
				                {field:'repartoyname',title:'仓库',width:120},
				                {field:'repartoyrack',title:'货架',width:70},
				                {field:'repartoyaddress',title:'货架位置',width:80},
				                {field:'positionnumber',title:'位置编号',width:80},
				                {field:'remark',title:'备注',width:80}
				            ]],
				            onShowPanel:function(){  //当下拉面板显示的时候触发
				            	var drow = $('#outoderdtl').datagrid('getSelected');
				                //var index = $('#outoderdtl').datagrid('getRowIndex', drow); 			            	
				            	//var  ed= $('#outoderdtl').datagrid('getEditor', {index:index,field:'goodnumber'});
				            	if(drow.clientid!=''){
					            	var rurl=path+'billdetail/getgoodsexistout.html?clientid='+drow.clientid;
					            	$(this).combogrid("grid").datagrid("reload", rurl); 
				            	}

				            },
				    onSelect: function(rowIndex,rowData){
				    	
				    	setTimeout(function () {
				    	     var drow = $('#outoderdtl').datagrid('getSelected');
			                 var index = $('#outoderdtl').datagrid('getRowIndex', drow);
			                 editRow1 = undefined;    
			 				 datagrid1.datagrid("acceptChanges");   
			 				 datagrid1.datagrid("unselectAll"); 
			                 datagrid1.datagrid('updateRow', { index: index, 
			                	 row: {  goodsbillno:rowData.goodsbillno,
				                		 goodnumber:rowData.stockrate,
				                		 goodname:rowData.goodname,
				                		 goodid:rowData.goodid,
				                		 unit:rowData.unit,
				                		 snno:rowData.snno,
				                		 beiyon:rowData.beiyon,
				                		 specifications:rowData.specifications,
				                		 repartoyname:rowData.repartoyname,
				                		 repartoyrack:rowData.repartoyrack,
				                		 repartoyaddress:rowData.repartoyaddress,
				                		 positionnumber:rowData.positionnumber,
				                		 putinid:rowData.id
			                		 } });
			                 datagrid1.datagrid("acceptChanges"); 
			                 $('#outoderdtl').datagrid('endEdit', index).datagrid('refreshRow', index).datagrid('selectRow', index).datagrid('beginEdit', index);
				    	},10);
//				    	
					}
				} }
			},
			{field:'specifications',title: '规格型号',align: 'center',width:80,sortablebill:true},
			{field:'goodsbillno',title: '物品编号',align: 'center',width:85,sortablebill:true,hidden:true},
			{field:'goodid',title: '物品ID',align: 'center',width:85,sortablebill:true,hidden:true}, 
			{field:'beiyon',title: '库存编号',align: 'center',width:85,sortablebill:true}, 
			{field:'goodnumber',title: '物品数量',align: 'center',width:55,sortablebill:true,editor: { type: 'numberbox', options: { required: true} }
			},
			{field:'unit',title: '物品单位',align: 'center',width:50,sortablebill:true},
			{field:'snno',title: 'SN',align: 'center',width:110,sortablebill:true,
				editor: { type: 'validatebox', options: { required: false} }
			},
			{field:'repartoyname',title: '仓库名称',align: 'center',width:50,sortablebill:true},
			{field:'repartoyrack',title: '货架',align: 'center',width:50,sortablebill:true},
			{field:'repartoyaddress',title: '货架位置',align: 'center',width:65,sortablebill:true},
			{field:'positionnumber',title: '位置编号',align: 'center',width:65,sortablebill:true},
			{field:'goodsgoout',title: '物品去向',align: 'center',width:65,sortablebill:true,
				editor: { type: 'validatebox', options: { required: true} }	
			}, 
			{field:'couriernumber',title: '快递单号',align: 'center',width:65,sortablebill:true,
				editor: { type: 'validatebox', options: { required: false} }	
			}, 
			{field:'putinid',title: '入库单id',align: 'center',width:85,sortablebill:true,hidden:true},
			{field:'ids',title: '功能',align: 'center',formatter:function(value,rowData,rowIndex){
				    if(tag==10){
				    	return '';
				    }else{
				    	return "<a href='#' onclick='del("+rowIndex+","+rowData.id+")'>删除</a>";
				    }
			        
			        
			   },width:65,sortablebill:true  
			}
	    ]],
	    toolbar: [{
			iconCls: 'icon-add',
			text:'新增',
			id:"dtladd",
			handler: function(){
				if(validateEidter("outoderdtl",arrname)==0){  //验证输入的数据
					$("#outoderdtl").datagrid("acceptChanges");   
					$("#outoderdtl").datagrid("unselectAll"); 
					
				if (editRow != undefined) {
                    $("#outoderdtl").datagrid('endEdit', editRow1);
                }
				if (editRow == undefined) {
					$("#outoderdtl").datagrid('appendRow', {        
	                        	clientname:'请必选 ',
	                        	goodsbillno:'请必填',
	                        	goodname:'请必选',
	                        	goodnumber:'0',
	                        	unit:'请填入',
	                        	snno:'请填入',
	                        	repartoyname:'请填入',
	                        	repartoyrack:'请填入',
	                        	repartoyaddress:'请填入',
	                        	goodsgoout:'请必填',
	                        	couriernumber:'',
	                        	putinid:''
	                    });
					editRow1 = 0;    
	               }
			}
			}
				
		},'-',
			{ text: '保存',id:"dtlsave", iconCls: 'icon-save', handler: function () {
				//var arrname=['客户姓名','物品名称','物品数量','当前序列码','物品去向'];
				  if(validateEidter("outoderdtl",arrname)==0){  //验证输入的数据
				editRow1 = undefined;    
				datagrid1.datagrid("acceptChanges");   
				datagrid1.datagrid("unselectAll"); 
				}
			 }
			}
			
		
		
		]
	});
  if(tag==10){
		$(".dialog-button").hide();
	}else{
		$(".dialog-button").show();
	}
}
/***
 * 删除新增表单中的明细数据 
 * @param index
 * @param id 当前行的id
 */
function del(index,rowid){
	//alert(rowsrt)
	var param="rows=删除&id="+rowid;
	  param = encodeURI(param);
	  param = encodeURI(param);	
	$.messager.confirm('确认对话框', '您想要删除此数据吗？', function(r){
		if (r){
			if(rowid!=null){
				 $.ajax({  //ajax删除明细数据
				      type:'post',      
				      url:path+'billdetail/delbilldate.html',  
				      data:param, 
				      cache:false,   
				      success:function(data){
				    	  if(data=='ok'){
				    		  $("#outoderdtl").datagrid('deleteRow',index);	
				    	  }else{
				    		  alert("删除失败！");
				    		  return false;
				    	  }
				    	  
				      },
				      error: function(jqXHR, textStatus, errorThrown) {
				    	  switch (jqXHR.status){  
				          case(500):  
				              alert("服务器系统内部错误");  
				              break;  
				          case(401):  
				              alert("未登录");  
				              break;  
				          case(403):  
				              alert("无权限执行此操作");  
				              break;  
				          case(408):  
				              alert("请求超时");  
				              break;  
				          default:  
				              alert("未知错误");  
				      }  
				      }
				  });
			}else{
				$("#outoderdtl").datagrid('deleteRow',index);	
			}
		}
	});  
}

function savedate(obj){
	editRow1 = undefined;    
  if(validateEidter("outoderdtl",arrname)==0){  //验证输入的数据
	$("#outoderdtl").datagrid("acceptChanges");   
	$("#outoderdtl").datagrid("unselectAll"); 
  var billtype='出库单';
  var billno=$("#billno").val();
  var remark=$("#remark").val();
  var tag=$("#tag").val();
  var id=$("#id").val();
  var datas=$("#outoderdtl").datagrid('getRows');
  var rowslist=JSON.stringify(datas);

  var param="tag="+tag+"&id="+id+"&billtype="+billtype+"&billno="+billno+"&remark="+remark+"&rows="+rowslist
  param = encodeURI(param);
  param = encodeURI(param);	
  $.ajax({  
      type:'post',      
      url:path+'billdetail/savebilldate.html',  
      data:param, 
      cache:false,   
      success:function(data){
    	  if(data.success){
	    	  $('#goods').datagrid('reload');
	    	  if(tag==0){
	    		  alert("新增数据成功");
	    	  }else if(tag==1){
	    		  alert("变更数据成功");
	    	  }
	    	  $('#goodsadd').window('close') 	;
    	  }else{
    		  alert(data.errorMsg);
    	  }
      },
      error: function(jqXHR, textStatus, errorThrown) {
    	  switch (jqXHR.status){  
          case(500):  
              alert("服务器系统内部错误");  
              break;  
          case(401):  
              alert("未登录");  
              break;  
          case(403):  
              alert("无权限执行此操作");  
              break;  
          case(408):  
              alert("请求超时");  
              break;  
          default:  
              alert("未知错误");  
      }  
      }
  }); 
    }
}
/**编辑数据***/
function editdate(){
	var rows=$("#goods").datagrid("getSelections");
	if(rows.length==1){
		$('#goodsadd').window('open');
		$('#addgoodsform')[0].reset();
		$('#goodsadd').panel('setTitle','编辑物品出库单');
		$("#billno").attr("value",mainrow.billno);
		$('#remark').textbox('setValue',mainrow.remark);
		$("#id").attr("value",mainrow.id);
		$('#remark').textbox('enable');
		$("#tag").attr("value","1");
		showdtl(1,mainrow.id);
	}else if(rows.length>1){
		$("#goods").datagrid("uncheckAll");	
		alert("编辑数据时只能选中一行数据进行编辑");
		return false;
	}else{
		alert("请选中一行数据进行编辑");
		return false;
	}
}

/**删除主数据 ***/
function delmaindate(){
	var rows=$("#goods").datagrid("getSelections");
	if(rows.length==0){
		alert("请选择数据！");
		return false;
	}
	$.messager.confirm('确认对话框', '您想要删除此数据吗？', function(r){
		if (r){
	
	var ids = [];
	for (var i = 0; i < rows.length; i++) {
        ids.push(rows[i].id); //注意修改你的id列
    }
	
	var param="rows="+JSON.stringify(rows)+"&ids="+ids.join(',');
	  param = encodeURI(param);
	  param = encodeURI(param);	
	$.ajax({  
	      type:'post',      
	      url:path+'billdetail/upatebilldatebyids.html?new='+Math.random(),  
	      data:param, 
	      cache:false,   
	      success:function(data){
	    	  $('#goods').datagrid('reload');
	    	  alert("删除数据成功");  	
	      },
	      error: function(jqXHR, textStatus, errorThrown) {
	    	  switch (jqXHR.status){  
	          case(500):  
	              alert("服务器系统内部错误");  
	              break;  
	          case(401):  
	              alert("未登录");  
	              break;  
	          case(403):  
	              alert("无权限执行此操作");  
	              break;  
	          case(408):  
	              alert("请求超时");  
	              break;  
	          default:  
	              alert("未知错误");  
	      }  
	      }
	  }); 
		}
	});
}
/******主表提交数据******/
function mainsubmit(){

	var rows=$("#goods").datagrid("getSelections");
	var ids = [];
	for (var i = 0; i < rows.length; i++) {
        ids.push(rows[i].id); //注意修改你的id列
    }
	if(rows.length==0){
		alert("请选择数据！");
		return false;
	}
	$.messager.confirm('确认对话框', '您想要提交选中数据吗？', function(r){
    if (r){
	var param="rows="+JSON.stringify(rows)+"&ids="+ids.join(',')+"&billtype=出库单";
	  param = encodeURI(param);
	  param = encodeURI(param);	
	$.ajax({  
	      type:'post',      
	      url:path+'billdetail/upatebilldatesubmitbyids.html?new='+Math.random(),  
	      data:param, 
	      cache:false,
	      dataType:'json', 
	      success:function(data){
	    	  var datas=data.rows;
	    	  if(datas.length>0){  //如果大于0说明有超额出库
	    		  order_detail(datas);
	    	  }else{
	    		  $('#goods').datagrid('reload');
		    	  alert("提交数据成功");  	
	    	  }	
	      },
	      error: function(jqXHR, textStatus, errorThrown) {
	    	  switch (jqXHR.status){  
	          case(500):  
	              alert("服务器系统内部错误");  
	              break;  
	          case(401):  
	              alert("未登录");  
	              break;  
	          case(403):  
	              alert("无权限执行此操作");  
	              break;  
	          case(408):  
	              alert("请求超时");  
	              break;  
	          default:  
	              alert("未知错误");  
	      }  
	      }
	  }); 
		}
	});
}
/**查看**/
function viewdate(id,billno,remark){
		$('#goodsadd').window('open');
		$('#addgoodsform')[0].reset();
		$('#goodsadd').panel('setTitle','编辑物品出库单');
		$("#billno").attr("value",billno);
		$('#remark').textbox('setValue',remark);
		$('#remark').textbox('disable');
		$("#id").attr("value",id);
		$("#tag").attr("value","1");
		//$('#ok').linkbutton('disable');
		showdtl(10,id);
	
}
/****
 * 导出当页
 */
function mainexp(){
	var rows=$("#goods").datagrid("getSelections");
	var ids = [];
	for (var i = 0; i < rows.length; i++) {
        ids.push(rows[i].id); //注意修改你的id列
    }
	if(rows.length==0){
		alert("请选择数据！");
		return false;
	}
	var  url=path+"billdetail/getexporttoexcl.html?ids="+ids.join(',')+"&billtype=出库单&new="+Math.random(); 
	url = encodeURI(url);
	url = encodeURI(url);
	window.open(url);
}
/**
 * 导出本页
 * 针对当前页的数据导出
 */
function mainthispagexp(){
	var field=$('#search1').searchbox('getName');
	var searchertext=$('#search1').searchbox('getValue');
	var  url=path+"report/getalldatetoexcl.html?field="+field+"&searchertext="+searchertext+"&billtype=出库单&new="+Math.random(); 
	url = encodeURI(url);
	url = encodeURI(url);
	window.open(url);
}
/*****
 * 
 * @param id div的id名称
 * @param arrname 中文数组
 * @returns {Number}
 */
function validateEidter(id,arrname) {
	
	var drow = $('#'+id).datagrid('getSelected');
    var index = $('#'+id).datagrid('getRowIndex', drow);
    var ed = $('#'+id).datagrid('getEditors',index);
    var vv="";
    var i=0;
    var i1=0;
    $.each(ed, function(idx, obj) {
       try {
    	   vv=obj.target.combo('getText');
		} catch (e) {
		   vv=obj.target.val();
		}
		i1=0;
		if(i<arrname.length){
		if(vv=="0"||vv=="请必填"||vv=="请必选"||vv==''){
			if(arrname[i]=='SN'){
				
			}else{
				alert("请设置【"+arrname[i]+"】的值!");
				i1=1;
				return false;
			}

		}}
		i++;
    });    
    
    return i1;
}

function formatDateTime(date) {  
    var y = date.getFullYear();  
    var m = date.getMonth() + 1;  
    m = m < 10 ? ('0' + m) : m;  
    var d = date.getDate();  
    d = d < 10 ? ('0' + d) : d;  
    var h = date.getHours();  
    var minute = date.getMinutes();  
    minute = minute < 10 ? ('0' + minute) : minute; 
    var s = date.getSeconds() + 1;  
    s = s < 10 ? ('0' + s) : s;
    return y + '' + m + '' + d+''+h+''+minute+''+s;  
}; 
function preZeroFill (num, size) {
    if (num >= Math.pow(10, size)) { //如果num本身位数不小于size位
        return num.toString();
    } else {
        var _str = Array(size + 1).join('0') + num;
        return _str.slice(_str.length - size);
    }
}


/**
 * 展示列表
 * @param data
 */
function order_detail(data) {
	var tbBody ='';
	  var even="background:#F2F9FC";
      var odd="background:#FFFFFF;";
		tbBody +="<tr  style='"+even+"'>" +
		"<th align='left'>客户名称</th>" +
		"<th align='left'>物品名称</th>" +
		"<th align='left'>规格型号</th> " +
		"<th align='left'>库存编号</th>" +
		"<th align='left'>实际库存量</th>" +
		"<th align='left'>当前出库量</th>" +
		"<th align='left'>超出库存量</th>" +
		"<th align='left'>仓库</th>" +
		"<th align='left'>货架</th>" +
		"<th align='left'>货架位置</th>" +
		"</tr>";
	jQuery.each(data,
			function(i, n) {
				if (i % 2 == 1) {
					tbBody +="<tr  style='"+even+"'>" +
					       "<td>"+n.clientname+"</td>" +
							"<td>"+n.goodname+"</td>" +
							"<td>"+n.specifications+" </td>" +
							" <td>"+n.beiyon+" </td>" +
							" <td>"+n.stockrate+" </td>" +
							" <td>"+n.ckd+" </td>" +
							" <td>"+n.rkd+" </td>" +
							" <td>"+n.repartoyname+" </td>" +
							" <td>"+n.repartoyrack+" </td>" +
							" <td>"+n.repartoyaddress+" </td>" +
							"</tr>";
				} else {
					tbBody +="<tr  style='"+odd+"'>" +
					"<td>"+n.clientname+"</td>" +
					"<td>"+n.goodname+"</td>" +
					"<td>"+n.specifications+" </td>" +
					" <td>"+n.beiyon+" </td>" +
					" <td>"+n.stockrate+" </td>" +
					" <td>"+n.ckd+" </td>" +
					" <td>"+n.rkd+" </td>" +
					" <td>"+n.repartoyname+" </td>" +
					" <td>"+n.repartoyrack+" </td>" +
					" <td>"+n.repartoyaddress+" </td>" +
					"</tr>";
				}
			});
	
	// 备注原因
	var html = "<div id='show_div' style='display:none; width:800px; height:300px; border:1px solid #218cc2; background:#eee; position: absolute; top: 25%; left: 22%;font-size:12px;'>" +
			"<div style='width:100%;background-color:#9ed9fb;overflow:hidden;font-size:12px'>" +
			"<div style='margin:5px 0px 5px 10px;color:red;font-size:18px;font-weight:bold;'>当前选择的出库单中的物品数量已超实际库存数量！请修改对应物品的出库数量后再提交！</div>" +
			"</div>" +
			"<table style='font-size:12px;width:100%' >"+tbBody+
			"</table>"+
			"<div style='float:right;margin:10px 10px 10px 10px'>" +
			"<input id='btnclose' type='button' value='关闭' onclick='hidediv();'/>" +
			"<span style='margin:0 12px'></span>" +
			"</div>" +
			"</div>";
	jQuery("body").append(html);
	jQuery("#show_div").css("display", "block");	
}
//隐藏DIV
function hidediv() {
	jQuery("#show_div").css("display", "none");
	jQuery("#show_div").remove();
}